
subdir('commonmeson')
subdir_versions = [
  #['object', '0', '0', '1'],
  #['software', '0', '0', '1'],
  #['device', '0', '0', '1'],
  #['interface', '0', '0', '1'],
  #['point', '0', '0', '1'],
  #['describe', '0', '0', '1'],
  ['xml', '0', '0', '2'],
  ['database', '0', '0', '1'],

  ['crc', '0', '0', '1'],
  ['hex', '0', '0', '1'],

  #['serial', '0', '0', '1'],
  ['email', '0', '0', '1'],
  ['account', '0', '0', '1'],

]
if host_machine.cpu_family() == 'arm'
elif host_machine.cpu_family() == 'aarch64'
subdir_versions += [
  ['http', '0', '0', '1'],
  #['httpd', '0', '0', '1'],
  #['socket', '0', '0', '1'],
  ['protocol', '0', '0', '1'],
  ['xml2json', '0', '0', '1'],
  ]
elif host_machine.cpu_family() == 'x86_64'
subdir_versions += [
  ['http', '0', '0', '1'],
  #['httpd', '0', '0', '1'],
  #['socket', '0', '0', '1'],
  ['protocol', '0', '0', '1'],
  ['yaml2json', '0', '0', '1'],
  ['xml2json', '0', '0', '1'],
  ]
else
endif
if host_machine.cpu_family() != 'arm'
if get_option('iec')
  subdir_versions += [
    #['iec', '0', '0', '1'],
    ]
endif
endif
if host_machine.cpu_family() != 'arm'
endif
inc_prefix = 'include/'
include_prefix = '../' + inc_prefix
common_inc_dir = include_prefix + 'base'
pkgconfig = import('pkgconfig')
install_flag = false
foreach item: subdir_versions
  target_name = item[0]
  major_version = item[1]
  minor_version = item[2]
  micro_version = item[3]
  target_version ='@0@.@1@.@2@'.format(major_version,minor_version,micro_version)
  args_name = '-DSOFTWARE_NAME="@0@"'.format(target_name)
if get_option('nonuse_glib')
  args_name += '-DNONUSE_GLIB="@0@"'.format(target_name)
endif
  args_version = '-DVERSION="@0@"'.format(target_version)
  c_args = [args_name, args_version]
  #install_dir = superprefix + get_option('lib_prefix') + target_name + get_option('lib_suffix'),
  install_dir = meson.current_source_dir() + '/../install/' + host_machine.cpu_family() + '/lib'
  include_dir = join_paths(include_prefix, target_name)
  subdir(item[0])
  #pc_file = pkgconfig.generate(libnow,
  #  extra_cflags : '-I${includedir}/'+target_name,#files(files_found),
  #  )
  # -> include/projname/header.h
  #headers = files(join_paths('include', target_name) + '/**/*.h')
  result = run_command('find', join_paths(inc_prefix, target_name),
    '-name', '*.h', check:true)
  if result.returncode() == 0
      files_found = result.stdout().strip().split('\n')
  else
      error('Failed to find .c files')
  endif
  headers = files(files_found)
  install_headers(headers, subdir : target_name)
  #install_man('foo.1') # -> share/man/man1/foo.1
  #install_data('datafile.dat', install_dir : get_option('datadir') / 'progname')
#  lib_target += ['lib'+target_name, target_version]
endforeach
if true
#meson compile -C _local cpScript
target = lib_target
now_target = lib_target
message('Source root: ' + meson.current_build_dir())
message('Build root: ' + meson.current_source_dir())
shellscript = meson.project_source_root()+'/script/'+host_machine.cpu_family()+'_deb.sh'
custom_target(
  'debsrc',
  command: ['bash', shellscript,
    meson.current_build_dir(), now_target],
  output: 'deb.txt'
)
endif
